package com.infonautics.dao.imp;

import java.util.List;

import com.hibernate.Company;
import com.hibernate.HibernateDao;
import com.hibernate.Taxprocess;
import com.infonautics.dao.ITaxprocessDao;
import com.infonautics.page.PageBean;
import com.system.dao.ISystemDao;

/**
 * 
 * @author 马萍
 * 报税流程dao实现类
 */
public class ITaxprocessDaoImp implements ISystemDao<Taxprocess>,ITaxprocessDao {

	HibernateDao<Taxprocess> taxprocessDao = new HibernateDao<Taxprocess>();
	/*
	 * 分页查询全部办税流程信息
	 * (non-Javadoc)
	 * @see com.infonautics.dao.ITaxprocessDao#doTaxprocessList(int, int)
	 */
	@Override
	public PageBean<Taxprocess> doTaxprocessList(int pageSize, int page)
			throws Exception {
		
		final String hql = "from Taxprocess order by id desc";
		int allRow = taxprocessDao.getAllRowCount("select count(*) from Taxprocess");
		
		int totalPage = PageBean.countTotalPage(pageSize, allRow);
		final int offset = PageBean.countOffset(pageSize, page);
		final int length = pageSize;
		final int currentPage = PageBean.countCurrentPage(page);
		List<Taxprocess> list = taxprocessDao.getObjects(hql, offset,length);
		
		PageBean<Taxprocess> pageBean = new PageBean<Taxprocess>();
		pageBean.setPageSize(pageSize);
		pageBean.setCurrentPage(currentPage);
		pageBean.setAllRow(allRow);
		pageBean.setTotalPage(totalPage);
		pageBean.setList(list);
		pageBean.init();
		return pageBean;
	}

	/*
	 * 分页条件查询报税流程
	 * (non-Javadoc)
	 * @see com.infonautics.dao.ITaxprocessDao#doQueryList(int, int, java.lang.String)
	 */
	@Override
	public PageBean<Taxprocess> doQueryList(int pageSize, int page, String sql)
			throws Exception {
		
		final String hql = "from Taxprocess where 1=1 "+sql+" order by id desc";
		int allRow = taxprocessDao.getAllRowCount("select count(*) from Taxprocess where 1=1 "+sql);
		
		int totalPage = PageBean.countTotalPage(pageSize, allRow);
		final int offset = PageBean.countOffset(pageSize, page);
		final int length = pageSize;
		final int currentPage = PageBean.countCurrentPage(page);
		List<Taxprocess> list = taxprocessDao.getObjects(hql, offset,length);
		
		PageBean<Taxprocess> pageBean = new PageBean<Taxprocess>();
		pageBean.setPageSize(pageSize);
		pageBean.setCurrentPage(currentPage);
		pageBean.setAllRow(allRow);
		pageBean.setTotalPage(totalPage);
		pageBean.setList(list);
		pageBean.init();
		return pageBean;
	}

	@Override
	public PageBean<Taxprocess> doList(int pageSize, int page, int id)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	/*
	 * 添加报税流程
	 * (non-Javadoc)
	 * @see com.system.dao.ISystemDao#doAdd(java.lang.Object)
	 */
	@Override
	public void doAdd(Taxprocess object) throws Exception {
		
		if(object != null){
			
			taxprocessDao.addObject(object);
		}
		
	}

	/*
	 * 修改报税流程
	 * (non-Javadoc)
	 * @see com.system.dao.ISystemDao#doModfiy(java.lang.Object)
	 */
	@Override
	public void doModfiy(Taxprocess object) throws Exception {
		
		if(object != null){
			
			taxprocessDao.updateObject(object);
		}
		
	}

	/*
	 * 删除报税流程
	 * (non-Javadoc)
	 * @see com.system.dao.ISystemDao#doDelete(int)
	 */
	@Override
	public void doDelete(int id) throws Exception {
		
		taxprocessDao.deleteObject(id, Taxprocess.class);
		
	}

	/*
	 * 根据id查询
	 * (non-Javadoc)
	 * @see com.system.dao.ISystemDao#doOne(int)
	 */
	@Override
	public Taxprocess doOne(int id) throws Exception {
		
		return taxprocessDao.getObject(id, Taxprocess.class);
	}

}
